﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;

namespace IHISCETeim.BLL
{
    public class UReturnVisitController:BaseController
    {
        public static bool Add(UReturnVisitInfo obj, List<UReturnVisitUsabilityDetailInfo> listVisit)
        {
            if (UReturnVisitUsabilityDetail_Add(listVisit))
            {
                return UReturnVisitDAL.Add(obj);
            }
            else
            {
                return false;               
            }
        }
        public static bool Update(UReturnVisitInfo obj, List<UReturnVisitUsabilityDetailInfo> listVisit)
        {
            
            if (UReturnVisitUsabilityDetail_Add(listVisit))
            {
                return UReturnVisitDAL.Update(obj);
            }
            else
            {
                return false;
            }
        }
        public static bool Delete(int UWCID)
        {
            return UReturnVisitDAL.Delete(UWCID);
        }
        public static UReturnVisitInfo GetByUWCID(int UWCID)
        {
            return CBO.FillObject<UReturnVisitInfo>(UReturnVisitDAL.GetByUWCID(UWCID));
        }
        public static DataTable GetPagination(string CustomerName, string SerialNumber, string AgentName, string AgentAddress, string CreateDateFrom, string CreateDateTo, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return UReturnVisitDAL.GetPagination(CustomerName, SerialNumber, AgentName, AgentAddress, CreateDateFrom, CreateDateTo, PageIndex, PageSize, Sort, ref  TotalCount);
        }

        /// <summary>
        /// 获取指定时间段内一个月交机回访报表数据
        /// </summary>
        /// <param name="CreateDateFrom"></param>
        /// <param name="CreateDateTo"></param>
        /// <returns></returns>
        public static DataTableCollection GetReport(string CreateDateFrom, string CreateDateTo,string VisitType)
        {
            return UReturnVisitDAL.GetReport(CreateDateFrom, CreateDateTo, VisitType);
        }
        /// <summary>
        /// 获取子问题的报表
        /// </summary>
        /// <param name="CreateDateFrom"></param>
        /// <param name="CreateDateTo"></param>
        /// <returns></returns>
        public static DataTableCollection GetVisitUsabilityReport(string CreateDateFrom, string CreateDateTo)
        {
            return UReturnVisitDAL.GetVisitUsabilityReport(CreateDateFrom, CreateDateTo);
        }

        /// <summary>
        /// 添加不满意项
        /// </summary>
        /// <param name="UWCID"></param>
        /// <param name="TempId"></param>
        /// <returns></returns>
        public static bool UReturnVisitUsabilityDetail_Add(List<UReturnVisitUsabilityDetailInfo> listVisit)
        {
            return UReturnVisitDAL.UReturnVisitUsabilityDetail_Add(listVisit);
        }
        //public static bool UReturnVisitUsabilityDetail_Delete(int UWCID)
        //{
        //    return UReturnVisitDAL.UReturnVisitUsabilityDetail_Delete(UWCID);
        //}
        public static List<UReturnVisitUsabilityDetailInfo> UReturnVisitUsabilityDetail_GetByUWCID(int UWCID)
        {
            return CBO.FillCollection<UReturnVisitUsabilityDetailInfo>( UReturnVisitDAL.UReturnVisitUsabilityDetail_GetByUWCID(UWCID));
        }
        public static List<UReturnVisitUsabilityTempInfo> UReturnVisitUsabilityTemp_GetByParId(int ParId)
        {
            return CBO.FillCollection<UReturnVisitUsabilityTempInfo>( UReturnVisitDAL.UReturnVisitUsabilityTemp_GetByParId(ParId));
        }
    }
}
